package com.ntschy.taizhou.service.impl;

import com.ntschy.taizhou.dao.StoreOrderCensusDao;
import com.ntschy.taizhou.entity.StoreOrderCensusDto;
import com.ntschy.taizhou.service.HomeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;


@Service
public class HomeServiceImpl implements HomeService {

    @Resource
    private StoreOrderCensusDao storeOrderCensusDao;





    @Override
    public List<String> getBrandName() {
        return storeOrderCensusDao.getBrandName();
    }

    @Override
    public List<String> getBusinessSegment() {
        return storeOrderCensusDao.getBusinessSegment();
    }

    @Override
    public List<String> getSector() {
        return storeOrderCensusDao.getSector();
    }

    @Override
    public List<String> getCategory() {
        return storeOrderCensusDao.getCategory();
    }

    @Override
    public List<String> getSalesDestination() {
        return storeOrderCensusDao.getSalesDestination();
    }

    @Override
    public StoreOrderCensusDto getAllCensus(String startTime, String endTime) {

        return   storeOrderCensusDao.getAllCensus(startTime,endTime);
    }

    @Override
    public String getMaxTime() {
        return storeOrderCensusDao.getMaxTime();
    }

    @Override
    public String getMinTime() {
        return  storeOrderCensusDao.getMinTime();
    }

    @Override
    public Map<String, Object> getGmvArea(String time, String brandName, String businessSegment, String sector, String category, String salesDestination) {
        Map<String, Object> map=new HashMap<>();
        BigDecimal gmv= storeOrderCensusDao.getGmvArea(time,brandName,businessSegment,sector,category,salesDestination);
        map.put("time",time);
        map.put("gmv",gmv);
        return map;
    }

    @Override
    public Map<String, Object> getRevenueArea(String time, String brandName, String businessSegment, String sector, String category, String salesDestination) {
        Map<String, Object> map=new HashMap<>();
        BigDecimal revenue= storeOrderCensusDao.getRevenueArea(time,brandName,businessSegment,sector,category,salesDestination);
        map.put("time",time);
        map.put("revenue",revenue);
        return map;
    }


//    @Override
//    public HomeSampelInfo getSampelInfo(LocalDate startDate, LocalDate endDate) {
//        CheckItemDictionaryEntity checkItemDictionaryEntity=new CheckItemDictionaryEntity();
//        List<CheckItemDictionaryEntity> checkItemDictionaryEntities= sampleDictionaryMapper.selectItemList(checkItemDictionaryEntity);
//        HomeSampelInfo homeSampelInfo=new HomeSampelInfo();
//        List<HomeSampelInfo.SampelInfo> sampelInfos=new ArrayList<>();
//       for (CheckItemDictionaryEntity checkItemDictionary:checkItemDictionaryEntities){
//            Integer count= sampleMapper.getSampelInfo(startDate,endDate,checkItemDictionary.getYwjc());
//           Integer rscount= sampleMapper.getSampelInfoRs(startDate,endDate,checkItemDictionary.getYwjc());
//           HomeSampelInfo.SampelInfo sampelInfo=new HomeSampelInfo.SampelInfo();
//           sampelInfo.setName(checkItemDictionary.getYwjc());
//           sampelInfo.setNum(Objects.isNull(count) ? 0: count);
//           sampelInfo.setYbnum(Objects.isNull(count) ? 0: count);
//           sampelInfo.setRsnum(rscount);
//           sampelInfos.add(sampelInfo);
//
//       }
//        homeSampelInfo.setSampelInfos(sampelInfos);
//        DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM");
//        String dateStr = fmt.format(startDate);
//
//        homeSampelInfo.setDateStr(dateStr);
//        return homeSampelInfo;
//    }

//    @Override
//    public Map<String, Object> pancakeData() {
//        Integer zrsCount=sampleMapper.peopleCount();
//        Map<String, Object> map=new HashMap<>();
//        map.put("zrsCount",zrsCount);
//        List< Map<String, Object>> maps=new ArrayList<>();
//        CheckItemDictionaryEntity checkItemDictionaryEntity=new CheckItemDictionaryEntity();
//        List<CheckItemDictionaryEntity> checkItemDictionaryEntities= sampleDictionaryMapper.selectItemList(checkItemDictionaryEntity);
//        for (CheckItemDictionaryEntity checkItemDictionary:checkItemDictionaryEntities) {
//            Integer count = sampleMapper.getSampelInfoZrs( checkItemDictionary.getYwjc());
//            Map<String, Object> objectMap=new HashMap<>();
//            objectMap.put(checkItemDictionary.getYwjc(),count);
//            maps.add(objectMap);
//        }
//        map.put("mapList",maps);
//        return map;
//    }

}
